<?
	/* View */
	define('PS', 1);
	include_once("../../defines.php");
	
	include_once('header.php');
	
	$PageName = 'contact';
	include_once(PUBLIC_BEHIND_DIRECTORY . $PageName . '.php');
?>

<script type="text/javascript">
	var defaultText = "Ingrese el texto...";
	$(function(){

		$("#btnAccept").click(function(){
			functions.validateAllCompleted();
			if (functions.errorExists()) return false;
			
			params = {
				pageToLoad : "<?= PUBLIC_CONTROLLERS_PATH;?>email.php",
				HTTPMethod : "post",
				parameters : $("#frmContact").serialize(),
				callbackFunction : function(){
					$.unblockUI();
					alert("Su mensaje ha sido enviado, gracias!");
					$(location).attr('href', '<?=MAIN_PATH;?>' + 'home');
				}
			};
			$.blockUI({message : '<div class="sendingMessage">Enviando...<img src="<?=PUBLIC_IMAGES_PATH . "sending.gif";?>" alt="Sending"/></div>'});
			functions.makeAjaxCall(params);
		});

		$(".contactText, textarea").click(function(){
			functions.setEmptyText(this, defaultText);
		});

		$(".contactText, textarea").focusin(function(){
			functions.setEmptyText(this, defaultText);
		});

		$(".contactText, textarea").focusout(function(){
			count = functions.trim($(this).val()).length;
			if (count == 0){
				$(this).addClass('emptyText');
				$(this).val(defaultText);
			}
		});

		$(".contactText, textarea").keypress(function(){
			if ($(this).val() != defaultText){
				$(this).removeClass('error');
				$(this).removeClass('emptyText');
			}
		});

		$.each($(".contactText.emptyText, textarea.emptyText"), function(){
			$(this).val(defaultText);
		});

	});
</script>

<div id="contactContent" class="centerContent">
	<h1 class="titlePage">Contactanos:</h1>

	<form id="frmContact" name="frmContact">
		<div id="formContent">
			<div class="contactLabel inlineBlock">Nombre y apellido: </div><input type="text" class="contactText requiredData emptyText inlineBlock" id="txtName" name="txtName" />
			<br />
			<div class="contactLabel inlineBlock">Email: </div><input type="text" class="contactText requiredData emptyText" id="txtEmail" name="txtEmail" />
			<br />
			<div class="contactLabel inlineBlock">Comentario: </div><textarea class="contactTextarea requiredData emptyText" id="txtComment" name="txtComment"></textarea>
			<input type="button" class="button" value="Aceptar" id="btnAccept" />
		</div>
	</form>
</div>

<? include('footer.php'); ?>